﻿Public Class LopDAO
    Public Shared Function SelectAll() As DataTable
        Dim strSQL As String = "select * from Lop"
        Dim dt As DataTable
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
    Public Shared Sub Insert(ByVal _lop As LopDTO)
        Dim strSQL As String = "Insert into Lop(Malop,Tenlop,Tenkhoa,Chuyennganh,Tenhe,Sosv,Nienkhoa)  Values('" & _lop.MaLop & "',N'" & _lop.TenLop & "',N'" & _lop.TenKhoa & "',N'" & _lop.ChuyenNganh & "',N'" & _lop.TenHe & "'," & _lop.SiSo & ",'" & _lop.NienKhoa & "')"
        SQLProvider.ExecNoneQuery(strSQL)

    End Sub
    Public Shared Sub Delete(ByVal _lop As LopDTO)
        Dim strSQL As String = "delete from Lop where Malop = '" & _lop.MaLop & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Sub Update(ByVal _lop As LopDTO)
        Dim strSQL As String = "Update Lop set Tenlop = N'" & _lop.TenLop & "', Tenkhoa = N'" & _lop.TenKhoa & "', Chuyennganh = N'" & _lop.ChuyenNganh & "', Tenhe = N'" & _lop.TenHe & "', Sosv = " & _lop.SiSo & ", Nienkhoa = '" & _lop.NienKhoa & "' where Malop = '" & _lop.MaLop & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Function SelectByLop(ByVal _lop As LopDTO) As DataTable
        Dim dt As DataTable
        Dim strSQL As String = "select * from Lop where Tenlop like N'%" & _lop.TenLop & "%'"
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
End Class
